package IOStream;

import java.io.*;

/*
    文件复制
 */
public class FileCopy {
    public static void main(String[] args) {
        File file1=new File("c:\\IOStream\\date02.txt");
        File file2=new File("C:\\IOStream\\date04.txt");
        FileInputStream fis=null;
        FileOutputStream fos=null;
        try {
            fis=new FileInputStream(file1);
            fos=new FileOutputStream(file2,false);
            int a=-1;
            byte chs[]=new byte[1024];
            while ((a=fis.read(chs))!=-1){
                fos.write(chs,0,a);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fis.close();
                fos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
